home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / acpi / lid.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-10-15  |  1.2 KB  |  46 lines

  1. #!/bin/bash
  2.  
  3. . /usr/share/acpi-support/power-funcs
  4. . /usr/share/acpi-support/policy-funcs
  5. . /etc/default/acpi-support
  6.  
  7. [ -x /etc/acpi/local/lid.sh.pre ] && /etc/acpi/local/lid.sh.pre
  8.  
  9. if [ `CheckPolicy` == 0 ]; then exit; fi
  10.  
  11. grep -q closed /proc/acpi/button/lid/*/state
  12. if [ $? = 0 ]
  13. then
  14.     for x in /tmp/.X11-unix/*; do
  15.     displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
  16.     getXuser;
  17.     if [ x"$XAUTHORITY" != x"" ]; then
  18.         export DISPLAY=":$displaynum"        
  19.         . /usr/share/acpi-support/screenblank
  20.     fi
  21.     done
  22. else
  23.     for x in /tmp/.X11-unix/*; do
  24.     displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
  25.     getXuser;
  26.     if [ x"$XAUTHORITY" != x"" ]; then
  27.         export DISPLAY=":$displaynum"
  28.         grep -q off-line /proc/acpi/ac_adapter/*/state
  29.         if [ $? = 1 ]
  30.         then
  31.         if pidof xscreensaver > /dev/null; then 
  32.             su $user -c "xscreensaver-command -unthrottle"
  33.         fi
  34.         fi
  35.         if [ x$RADEON_LIGHT = xtrue ]; then
  36.         [ -x /usr/sbin/radeontool ] && radeontool light on
  37.         fi
  38.         if [ `pidof xscreensaver` ]; then
  39.         su $user -c "xscreensaver-command -deactivate"
  40.         fi
  41.         su $user -c "xset dpms force on"
  42.     fi
  43.     done
  44. fi
  45. [ -x /etc/acpi/local/lid.sh.post ] && /etc/acpi/local/lid.sh.post
  46.